const ValidatorError = require('../../shared/errors/ValidatorError')

class RoleError extends ValidatorError {
  constructor(message, status = 400) {
    super(message)
    this.status = status
  }
}

class RoleNotFoundError extends RoleError {
  constructor(id) {
    super(`角色【${id}】不存在`)
  }
}

class RoleHasMenuBindingError extends RoleError {
  constructor(name) {
    super(`角色【${name}】还绑定着菜单，请先移除菜单绑定关系`)
  }
}

class RoleHasUserBindingError extends RoleError {
  constructor(name) {
    super(`角色【${name}】还有用户绑定，请先移除用户绑定关系`)
  }
}

class RoleCodeExistError extends RoleError {
  constructor(code) {
    super(`角色编码 【${code}】 已存在`)
  }
}

module.exports = {
  RoleCodeExistError,
  RoleError,
  RoleHasMenuBindingError,
  RoleNotFoundError,
  RoleHasUserBindingError,
}
